<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
  
  <head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="manager/css/font.css">
    <link rel="stylesheet" href="manager/css/xadmin.css">
      <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
      <script src="https://cdn.bootcss.com/jquery.form/3.51/jquery.form.js"></script>
    <script type="text/javascript" src="manager/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="manager/js/xadmin.js"></script>
      <style>
          select{
              width: 200px;
              height: 38px;
              display: block;
          }
      </style>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  
  <body>
    <div class="x-body layui-anim layui-anim-up">
        <select onchange="$('input[name=\'r_kind\']').val($('select').val())">
            <option value="1">销售类</option>
            <option value="2">市场类</option>
            <option value="3">技术类</option>
            <option value="4">职能类</option>
        </select>
        <form class="layui-form" enctype="multipart/form-data">
            <input type="hidden" name="r_kind" value="1" />
          <div class="layui-form-item">
              <label class="layui-form-label">
                  <span class="x-red">*</span>职位
              </label>
              <div class="layui-input-inline">
                  <input type="text" name="r_position" required="" lay-verify="pass"
                  autocomplete="off" class="layui-input">
              </div>
          </div>

          <div class="layui-form-item">
              <label class="layui-form-label">
                  <span class="x-red">*</span>学历要求
              </label>
              <div class="layui-input-inline">
                  <input type="text" name="r_education" required="" lay-verify="pass"
                  autocomplete="off" class="layui-input">
              </div>
          </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>招聘人数
            </label>
            <div class="layui-input-inline">
                <input type="number" name="r_number" required="" lay-verify="pass"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                <span class="x-red">*</span>工作地点
            </label>
            <div class="layui-input-inline">
                <input type="text" name="r_place" required="" lay-verify="pass"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>职位描述
                </label>
                <div class="layui-input-block">
                    <textarea placeholder="请输入内容" id="desc" name="r_desc" class="layui-textarea"></textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    <span class="x-red">*</span>岗位需求
                </label>
                <div class="layui-input-block">
                    <textarea placeholder="请输入内容" id="desc" name="r_require" class="layui-textarea"></textarea>
                </div>
            </div>
          <div class="layui-form-item">
              <label class="layui-form-label">
              </label>
              <button  class="layui-btn" lay-filter="add" lay-submit="">
                  增加
              </button>
          </div>
      </form>
    </div>
    <script>

        layui.use(['form','layer'], function(){
            $ = layui.jquery;
          var form = layui.form
          ,layer = layui.layer;
        
          //自定义验证规则
          form.verify({

            pass: function (value) {
                if(value.length<1){
                    return '不能为空';
                }
            }
          });

          //监听提交
          form.on('submit(add)', function(data){
                //发异步，把数据提交给php
              $.ajax({
                  url:"addRecruit",
                  data:data.field,
                  type:"post",
                  success:function (result) {
                      if(result.result=="0000"){
                          layer.alert("增加成功", {icon: 6},function () {
                              // 获得frame索引
                              var index = parent.layer.getFrameIndex(window.name);
                              window.parent.location.reload()
                              //关闭当前frame
                              parent.layer.close(index);
                          });
                      }else{
                          layer.msg(result.resultMsg,{icon:1,time:1000});
                      }
                  },
                  dataType:"json"
              })
            return false;
          });
        });
    </script>
  </body>

</html>